﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：JsonResultDateTimeConverter.cs
// 功能描述：TongTongMall.MallWeb
// 
// Create User：jym 2017/02/09
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;

namespace TongTongMall.MallWeb.WebApi.Core.Converters
{
    public class JsonResultDateTimeConverter : IsoDateTimeConverter
    {

        public JsonResultDateTimeConverter()
        {
            DateTimeFormat = "yyyyMMddHHmmss";
        }

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value is DateTime || (value is DateTime? && value != null))
            {
                base.WriteJson(writer, value, serializer);
            }
            else
            {
                writer.WriteValue("");
            }
        }
    }
}